package com.demo.test.generic;

public class MyAdd<T> {

	public <T extends Number> Double add(T t1,T t2) {
		double num=0;
		if(t1 instanceof Integer) {
			num=(Integer)t1.intValue();
		}else if(t1 instanceof Long) {
			num=(Long)t1.longValue();
		}else if(t1 instanceof Short) {
			num=(Short)t1.shortValue();
		}else if(t1 instanceof Float) {
			num=(Float)t1.floatValue();
		}else if(t1 instanceof Double) {
			num=(Double)t1.doubleValue();
		}
		double num2=0;
		if(t2 instanceof Integer) {
			num2=(Integer)t2.intValue();
		}else if(t1 instanceof Long) {
			num2=(Long)t2.longValue();
		}else if(t1 instanceof Short) {
			num2=(Short)t2.shortValue();
		}else if(t1 instanceof Float) {
			num2=(Float)t2.floatValue();
		}else if(t1 instanceof Double) {
			num2=(Double)t2.doubleValue();
		}
		
		return num+num2;
	} 
	public static void main(String[] args) {
		MyAdd<Number> my = new MyAdd<Number>();
		Double d = my.add(10.1, 1.5f);
		
		
		MyAdd<?> m1 = null;
		MyAdd<String> m2 = null;
		m1 = m2;
		
		
	}
}